knitr::opts_chunk$set(echo = TRUE)

Tasks

Task 1

Obtain the working directory.

getwd()

Task 2

Read in the DDT data.

ddt <- read.csv("DDT.csv")
head(ddt)

Task 3

a. The qualitative variables are RIVER and SPECIES. b. The quantitative variables are MILE, LENGTH, WEIGHT, and DDT. c. The ddt data has 3 species. d. Show only entries with species LMBASS and weight >800g.

with(ddt,ddt[SPECIES=="LMBASS" & WEIGHT>800,])

e. Show only entries with river SCM and DDT >4.0.

with(ddt,ddt[RIVER=="SCM" & DDT>4.0,])

Clicker Questions

Q1. Find the mean of the lengths.

mean(ddt$LENGTH)

Q2. Find the standard deviation of the weights.

sd(ddt$WEIGHT)

Q3. Does the image match the plot of length vs weight? Answer: No

plot(LENGTH~WEIGHT,data=ddt)

Q4. If v=1:20, the last value of v/20 is 1.

v=1:20
v/20

Task 4

Make tables and barplots.

riv = with(ddt,table(RIVER))
riv
barplot(riv,col=1:4)
rivsp = with(ddt,table(RIVER,SPECIES))
rivsp
barplot(rivsp)

Task 5

Make pie charts.

sp = with(ddt,table(SPECIES))
pie(sp)
pie(riv)

Task 6

Make boxplots.

boxplot(DDT~SPECIES,data=ddt)
boxplot(WEIGHT~SPECIES,data=ddt)
boxplot(LENGTH~RIVER,data=ddt)

Task 7

Make coplots.

coplot(LENGTH~WEIGHT|RIVER,data=ddt)
coplot(DDT~WEIGHT|SPECIES,data=ddt)

Task 8

Use ggplot to make different types of plots.

library(ggplot2)
ggplot(data=ddt,aes(x=SPECIES,y=WEIGHT,fill=RIVER))+geom_boxplot()+ggtitle("Drake Taylor")
ggplot(data=ddt,aes(x=RIVER,y=LENGTH,fill=SPECIES))+geom_violin()+ggtitle("Drake Taylor")
ggplot(data=ddt,aes(x=WEIGHT,y=LENGTH,color=SPECIES))+geom_point()+ggtitle("Drake Taylor")


draket333/MATH4753tayl0062 documentation built on Sept. 10, 2020, 11:49 a.m.